﻿/// <reference path="../Index.html" />
var uri = document.location.search;//接收页面传值
var i = uri.lastIndexOf("?") + 1;//获取问号前面的值
var P_ReportNumbers = uri.substr(i);//截取问号前面的值
//Wap显示的主页面
$(function () {
    $.ajax({
        type: "get",
        url:ApiUrl + "api/Personal/WapShow",
        data:{S_account: LoginUserAccount},
        success: function (data, status) {
            $("#Tosurvey").empty();
            $("#Stayaround").empty();
            $("#Havesurvey").empty();
            $(data).each(function (i, item) {
                if (item.T_State == 0) //0:待约勘，1:待查勘, 2:已查勘 
                {
                    var li = '<li style="height:80px">'
                    + '<a href="detail.html?' + item.T_ReportNumber + '">'
                    + '<dl class="mq_word" style="left:0px">'
                    + '<dd class="mq_com_n">'
                    + '报告编号：' + item.T_ReportNumber + ''
                    + '</dd>'
                    + '<dd>'

                    + '地址：' + item.T_Located + ''
                    + '</dd>'
                    + '<dd>'
                    + '联系人：' + item.T_Linkman + ''
                    + '</dd>'
                    + '<dd>'
                    + '联系人电话：' + item.T_Phone + ''
                    + '</dd>'
                    + '</dl>'
                    + '</a>'
                    + ' </li>';

                    $("#Stayaround").append(li);
                }
                if (item.T_State == 1) //0:待约勘，1:待查勘, 2:已查勘 
                {
                    var li1 = '<li style="height:80px">'
                                 + '<a href="detail.html?' + item.T_ReportNumber + '">'
                                 + '<dl class="mq_word" style="left:0px">'
                                 + '<dd class="mq_com_n">'
                                 + '报告编号：' + item.T_ReportNumber + ''
                                 + '</dd>'
                                 + '<dd>'
                                 + '地址：' + item.T_Located + ''
                                 + '</dd>'
                                 + '<dd>'
                                 + '联系人：' + item.T_Linkman + ''
                                 + '</dd>'
                                 + '<dd>'
                                 + '联系人电话：' + item.T_Phone + ''
                                 + '</dd>'
                                 + '</dl>'
                                 + '</a>'
                                 + ' </li>';

                    $("#Tosurvey").append(li1);
                }
                if (item.T_State >= 2) //0:待约勘，1:待查勘, 2:已查勘  //2016年11-21修改 手机端状态大于等于2的为已查勘 
                {
                    var li2 = '<li style="height:80px">'
                                   + '<a href="detail.html?' + item.T_ReportNumber + '">'
                                   + '<dl class="mq_word" style="left:0px">'
                                   + '<dd class="mq_com_n">'
                                   + '报告编号：' + item.T_ReportNumber + ''
                                   + '</dd>'
                                   + '<dd>'
                                   + '地址：' + item.T_Located + ''
                                   + '</dd>'
                                   + '<dd>'
                                   + '联系人：' + item.T_Linkman + ''
                                   + '</dd>'
                                   + '<dd>'
                                   + '联系人电话：' + item.T_Phone + ''
                                   + '</dd>'
                                   + '</dl>'
                                   + '</a>'
                                   + ' </li>'

                    $("#Havesurvey").append(li2);
                }
            })
        }
    })
})
//约没约成
function updatedetail() {
    var radio = $(".ds:checked").attr("id");
    var uri = document.location.search;//接收页面传值
    var i = uri.lastIndexOf("?") + 1;  //获取问号前面的值
    var P_ReportNumber = uri.substr(i);//截取问号前面的值
    var T_Cause = $("#T_Cause").val();
    if (radio == "Yes") {
        $.ajax({
            type: "get",
            url: ApiUrl + "api/Personal/UpdateP_ReportNumberyes",
            data: {
                P_ReportNumber: P_ReportNumber,
                P_cause: T_Cause
            },
            //contentType: 'application/json',
            success: function (data, status) {
                if (data == true) {

                    layer.msg('保存成功!', { icon: 1, time: 1000 });
                    location.href = "Index.html";
                }
                else {
                    layer.msg('保存失败!', { icon: 2, time: 1000 });
                }

            }
        })
    }
    if (radio == "NO") {
        $.ajax({
            type: "get",
            url: ApiUrl + "api/Personal/UpdateP_ReportNumberNO",
            data: {
                P_ReportNumber: P_ReportNumber,
                P_cause: T_Cause
            },
            //contentType: 'application/json',
            success: function (data, status) {
                if (data == true) {
                    layer.msg('保存成功!', { icon: 1, time: 1000 });
                }
                else {
                    layer.msg('保存失败!', { icon: 2, time: 1000 });
                }

            }
        })
    }
}
//点击查询查询出房屋的信息
function search() {
    var keyword = $("#keyword").val();
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Personal/searchbyP_located",
        data: {
            C_project: keyword
        },
        success: function (data, status) {

            $("#CommunityShow").empty();
            $(data).each(function (i, item) {
                var lis = "<li>"
                              + "<a href=\"#\" onclick=\"Import('" + item.T_ReportNumber + "')\">"
                              + "  <dl>"
                              + "      <dt>" + item.T_Project + "</dt>"
                              + "    <dd>"
                              + "      " + item.T_Located + ""
                              + "    </dd>"
                              + "    <dd class=\"area\">"
                              + "      " + item.T_Buildingafew + "号楼"
                              + "    </dd>"
                              + " </dl>"
                              + " </a>"
                              + "</li>";
                $("#CommunityShow").append(lis);
            })

        }
    })

}
//导入信息
function Import(P_ReportNumber) {
    parent.layer.confirm('确认要复用吗？', function () {
        $.ajax({
            type: "get",
            url: ApiUrl + "api/Personal/selectandupdate",
            data: {
                searchP_ReportNumber: P_ReportNumber,
                P_ReportNumbers: P_ReportNumbers,
            },
            //async: false,
            success: function (data, status) {
                if (status == "success") {
                    layer.msg('复用成功!', { icon: 1, time: 1000 });
                }
            }
        })
        $.ajax({
            type: "get",
            url: ApiUrl + "api/Personal/UpdateT_StartDateAndT_EndDate",
            data: { P_ReportNumber: P_ReportNumber },
            //async: false,
            success: function (data, status) {
                if (data) {
                    layer.msg('定位确认成功!', { icon: 1, time: 1000 });
                }
            }
        })
    }

    )

}


